package com.augurit.gzcgwsp.csshlj.convert;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.dozer.DozerBeanMapper;

import com.augurit.gzcgwsp.csshlj.entity.Csshljcz;
import com.augurit.gzcgwsp.csshlj.web.form.CsshljCzForm;
import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.CsshljczForFx;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComQyxxForm;

/**
 * 处置
 * @author Administrator
 *
 */

public class YwHwCzConvertor {
    public static CsshljCzForm convertVoToForm(Csshljcz entity) {
        if (entity == null) return null;
        CsshljCzForm form = new DozerBeanMapper().map(entity, CsshljCzForm.class);        
        return form;
    }
    
    public static void convertFormToQyxxForm(CsshljCzForm form, YwComQyxxForm qyxxForm) {
        if (form == null) return;
        if (qyxxForm == null) qyxxForm = new YwComQyxxForm();

        new DozerBeanMapper().map(form, qyxxForm);
        if(StringUtils.isNotBlank(form.getQybh())){
        	qyxxForm.setId(Long.parseLong(form.getQybh()));
        }
    }

    public static void convertQyxxFormToForm(YwComQyxxForm qyxxForm, CsshljCzForm form) {
        if (qyxxForm == null) return;
        if (form == null) form = new CsshljCzForm();
        
        new DozerBeanMapper().map(qyxxForm, form);
        form.setQybh(qyxxForm.getId().toString());
    }
    
    public static void convertFormToVo(CsshljCzForm form, Csshljcz entity) {
        if (form == null) return;
        if (entity == null) entity = new Csshljcz();
        
        new DozerBeanMapper().map(form, entity);
    }
    
    public static List<CsshljCzForm> convertVoListToFormList(List<Csshljcz> ywHwCzList) {
        if(ywHwCzList != null && ywHwCzList.size() > 0) {
            List<CsshljCzForm> czFormList = new ArrayList();
            for(int i=0; i<ywHwCzList.size(); i++) {
            	czFormList.add(convertVoToForm(ywHwCzList.get(i)));
            }
            return czFormList;
        }
        return null;
    }
    
    public static List<Csshljcz> convertFormListToVoList(List<CsshljCzForm> czFormList) {
        if(czFormList != null && czFormList.size() > 0) {
            List<Csshljcz> ywSrCzList = new ArrayList();
            for(int i=0; i<czFormList.size(); i++) {
                Csshljcz Csshljcz = new Csshljcz();
                convertFormToVo(czFormList.get(i), Csshljcz);
                ywSrCzList.add(Csshljcz);
            }
            return ywSrCzList;
        }
        return null;
    }
    
    public static void convertFormToCsshljczForFx(CsshljCzForm form, CsshljczForFx entity) {
        if (form == null) return;
        if (entity == null) entity = new CsshljczForFx();        
        new DozerBeanMapper().map(form, entity);
    }
}